<?php
/*
*Project	:dongzhan
*Version	:0.0.1
*Author		:xuhongquan
*Update		:2009-4-25
*Content	:php by Editplus
*/
header("Content-type: text/html; charset=utf-8");
require_once("../include/conn.php");

echo '<link href="Admin_Style.css" rel="stylesheet" type="text/css">';
echo '<title class="topbg">滚动图片设置</title>';
echo "<center class=\"topbg\">请在下列图片中选择一个作为本条信息的滚动图片，然后点击应用按钮。</center>" ;
if (isset($_POST['update'])) {
//	dump($_POST);//exit;
	if (isset($_POST['isshow'])) {
		$sqlup='';
		$isshow=$_POST['isshow'];
		if (is_array($isshow)) {
			foreach ($isshow as $show) {
				$isid=intval($show);
				if ($isid=='-1') {
					$isshow=0;
					break;
				}				
//				echo '<br>id='.$isid;
				if (empty($sqlup)) {
					$sqlup=' and id=\''.$isid.'\'';
				}else{
					$sqlup=$sqlup.' or id=\''.$isid.'\'';
				}				
			}
			
		}		
	}	
//	exit;	
	$sql='update '.$tb_mp.' set isshow=\'0\' where bl_id=\''.$id.'\'';
	if (!empty($sqlup)) {
		$sqlchg='update '.$tb_mp.' set isshow=\'1\' where bl_id=\''.$id.'\'' .$sqlup;
	}else {
		$sqlchg='';
	}	
//	echo 'sql1='.$sql;
//	echo '<br>sql2='.$sqlchg;
//	exit;	
	if ($isshow==0) {
		mysql_db_query($db_name,$sql);
	}else {	
		mysql_db_query($db_name,$sql);
		mysql_db_query($db_name,$sqlchg);
	}
	echo "<script>alert('操作成功！本页将关闭！');window.close();</script>";
}else {
	if (isset($_GET['id']) && !empty($_GET['id'])) {
	$id=$_GET['id'];
	$table=$_GET['souced'];
	}else {
		$id=0;
		exit('para error!');
	}
	$isshow=-1;
?>
<table border='0'>
	<form action="" method="post" name="from1">
	
	<?php $sql='select * from '.$tb_mp.' where bl_id=\''.$id.'\'';
	$con   =   mysql_db_query($db_name,$sql); 
	while($row = mysql_fetch_array($con)) {	
		if ($row['isshow']=='0') {
			$isshow=0;
		}		
	?>	
	<tr>
	<td><input name="isshow[]" type="radio" id="isshow" value="<?php echo $row['id'];?>" <?php if($row['isshow']=='1') echo "checked";?>>选择为启用
	</td><td><a href="<?php if(!empty($row['url'])) echo $row['url'];?>" title="点击图片，放大观看" target="_blank"><img src="<?php if(!empty($row['url'])) echo $row['url'];?>" width='80' height='45' border='0' /></a>
	</td>
	</tr><tr><?php }?>	
	<td><input name="isshow[]" type="radio" id="isshow" value="-1" <?php if($isshow=='0') echo "checked";?>>取消选择  
	</td>
	</tr>	
	<td><input type="submit" name="update" value="应用">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <input type="button" name="close" value="退出" onclick="window.close();"></td>
	</tr>
	</form>
	</table>
<?php 
}
?>


